# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer:  Francesco Colista <fcolista@alpinelinux.org>
pkgname=py3-sip
_pkgname=sip
pkgver=4.19.23
pkgrel=1
pkgdesc="A tool that makes it easy to create Python bindings for C and C++ libraries"
options="!check" # No testsuite
url="http://www.riverbankcomputing.com/software/sip/"
arch="all"
license="custom:sip"
makedepends="python3-dev"
subpackages="
	$pkgname-pyqt5
	$pkgname-dev::noarch
	$pkgname-doc"
source="https://www.riverbankcomputing.com/static/Downloads/$_pkgname/$pkgver/$_pkgname-$pkgver.tar.gz"
builddir="$srcdir"/$_pkgname-$pkgver

replaces="py-sip" # Backwards comptibility
provides="py-sip=$pkgver-r$pkgrel" # Backwards comptibility

prepare() {
	default_prepare
	mkdir -p "$srcdir"/python3-sip
	mkdir -p "$srcdir"/python3-PyQt5.sip
}

build() {
	cd "$srcdir"/python3-sip
	python3 "$builddir"/configure.py CFLAGS="$CFLAGS" LFLAGS="$LDFLAGS"

	cd "$srcdir"/python3-PyQt5.sip
	python3 "$builddir"/configure.py CFLAGS="$CFLAGS" LFLAGS="$LDFLAGS" --sip-module PyQt5.sip --no-tools
}

package() {
	cd "$srcdir"/python3-sip
	make DESTDIR="$pkgdir" install

	# Move sip.h to /usr/include
	mv "$pkgdir"/usr/include/python3*/sip.h "$pkgdir"/usr/include/sip.h
	rm -rf "$pkgdir"/usr/include/python3*

	install -Dm644 "$builddir"/LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

pyqt5() {
	pkgdesc="Python3 SIP bindings for C and C++ libraries"

	replaces="" # Reset
	provides="" # Reset

	cd "$srcdir"/python3-PyQt5.sip
	make DESTDIR="$subpkgdir" install
}

dev() {
	replaces="py-sip-dev" # Backwards compatibility
	provides="py-sip-dev=$pkgver-r$pkgrel" # Backwards compatibility

	depends_dev="py3-sip" # Depend on the package that provides the sip binary
	default_dev
}

sha512sums="a50c6202ebb6a5d1c98b6fc79925fa5d82236a944003854b057be9e2f7340d5cd689ba0e08f46f521736f3574c4089768c869bb8921e66b23944a31a832770f1  sip-4.19.23.tar.gz"
